package com.onesports.intelligent.k12.polarlight.service.organization;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.onesports.intelligent.k12.polarlight.domain.entity.organization.CampusStaffRel;
import com.onesports.intelligent.k12.polarlight.mapper.organization.CampusStaffRelMapper;
import com.onesports.intelligent.k12.polarlight.mapper.organization.CoachCampusRelMapper;
import com.onesports.intelligent.k12.polarlight.mapper.organization.CoachMapper;
import com.onesports.intelligent.k12.polarlight.mapper.organization.OrganizationStaffMapper;
import jodd.util.StringUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author aj
 **/
@Service
@RequiredArgsConstructor
public class StaffService {
    private final CampusStaffRelMapper campusStaffRelMapper;

    /**
     * 查询员工校区
     *
     * @param staffId
     * @param orgId
     * @return
     */
    public List<String> listCampusPermission(String staffId, String orgId) {
        List<CampusStaffRel> campusStaffRels = campusStaffRelMapper.selectList(
                new LambdaQueryWrapper<CampusStaffRel>()
                        .eq(CampusStaffRel::getStaffId, staffId)
                        .eq(CampusStaffRel::getOrganizationId, orgId)
        );
        if (CollectionUtils.isNotEmpty(campusStaffRels)) {
            return campusStaffRels.stream().map(CampusStaffRel::getCampusId).collect(Collectors.toList());
        }
        return null;
    }
}
